# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=w32pth
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0.5
pkgrel=3
pkgdesc="An emulation of PTH for MS Windows (mingw-w64)"
arch=('any')
license=("LGPL")
url="https://gnupg.org"
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('strip' 'staticlibs')
source=(https://github.com/gpg/w32pth/archive/w32pth-${pkgver}.tar.gz
        w32pth-2.0.4-deffile.patch
        w32pth-2.0.4-mingw.patch)
sha256sums=('cb5107a5544a4800f6b9faae5e977c6a11ef2e38af4f23dccc5a179df8f934ef'
            '963dcc6585173c0d184d876a5782b1b5a40aeec0e7d7001e653b4d5fab83ae85'
            '3bbb51002ad54f451a52573122435e57b7a4d966e4d2788859b937378f6f5443')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/w32pth-2.0.4-deffile.patch
  patch -p1 -i ${srcdir}/w32pth-2.0.4-mingw.patch

  ./autogen.sh
}

build() {
  export lt_cv_deplibs_check_method='pass_all'
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p ${srcdir}/build-${MINGW_CHOST} && cd ${srcdir}/build-${MINGW_CHOST}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --enable-shared \
    --disable-static
  make
}

package() {
  cd ${srcdir}/build-${MINGW_CHOST}
  make -j1 DESTDIR="${pkgdir}" install
  rm ${pkgdir}${MINGW_PREFIX}/lib/*.def
}
